<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>layui</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<link rel="stylesheet" href="__static/lib/layui-v2.5.5/css/layui.css" media="all">
	<link rel="stylesheet" href="__static/css/public.css" media="all">
	<style>
		.layui-form-pane .layui-form-label {
			width: 90px;
		}
	</style>
</head>
<body>
<div class="layuimini-container">
	<div class="layuimini-main">
		<fieldset class="table-search-fieldset">
			<legend>搜索信息</legend>
			<form class="layui-form layui-form-pane" action="">
				<div class="layui-form-item" style="margin-bottom: 5px;">
					<div class="layui-inline">
						<label class="layui-form-label">客户</label>
						<div class="layui-input-inline">
							<select name="id" lay-search="" autocomplete="off">
								<option value="" >直接选择或搜索选择</option>
								{volist name="cu_list" id="vo"}
									<option value="{$vo.id}" >{$vo.name}</option>
								{/volist}
					        </select>
						</div>
					</div>
					<div class="layui-inline">
						<label class="layui-form-label">媒介</label>
						<div class="layui-input-inline">
							<select name="media_id" lay-search="" autocomplete="off">
								<option value="" >直接选择或搜索选择</option>
								{volist name="media_list" id="vo"}
									<option value="{$vo.id}" >{$vo.username}</option>
								{/volist}
					        </select>
						</div>
					</div>
					<div class="layui-inline">
						<button type="submit" class="layui-btn layui-btn-primary"  lay-submit lay-filter="data-search-btn"><i class="layui-icon"></i> 搜 索</button>
					</div>
				</div>
			</form>
		</fieldset>
		<table class="layui-hide" id="currentTableId" lay-filter="currentTableFilter"></table> 
		<script type="text/html" id="currentTableBar">
			<a class="layui-btn layui-btn-normal layui-btn-xs data-count-edit" lay-event="mx">明细</a>
		</script>
	</div>
</div>
<script src="__static/lib/layui-v2.5.5/layui.js" charset="utf-8"></script>
<script src="__static/js/lay-config.js?v=1.0.4" charset="utf-8"></script>
<script src="__static/js/man.js" charset="utf-8"></script>
<script>
	var $,form,table,laydate,tableSelect,miniTab;
	layui.use(['form', 'table', 'tableSelect', 'laydate', 'miniTab'], function () {
		$ = layui.jquery
			, form = layui.form
			, table = layui.table
			, laydate = layui.laydate
            , tableSelect = layui.tableSelect
            , miniTab = layui.miniTab
			;
		pageLoading();
		table.render({
			elem: '#currentTableId',
			id:'testReload',
			height: 'full-150',
			url: '{:url("customer_ready")}?t=json',
			method : 'post',
			toolbar: '#toolbarDemo',
			loading:false,
			totalRow: true,
			cols: [[
				{ field: 'name', title: '客户名称', totalRowText: '合计'},
				{ field: 'username', title: '媒介'},
				{ field: 'prepare_money', align: 'right', title: '备款',sort: true ,style:' color: red;font-weight: bold;', totalRow: true},
				{ field: 'frozen_money', align: 'right', title: '冻结备款',sort: true ,style:' color: red;font-weight: bold;', totalRow: true},
				{ field: 'create_time', title: '创建时间', sort: true },
				{ field: 'note', title: '备注',width:160},
				{ title: '操作',fixed: 'right', toolbar: '#currentTableBar', align: "center",width:130 }
			]],
			limit: 30,
			page: true,
			done: function () {
                // 添加分页加载动画的函数    
                $('.layui-laypage > a').each(function(){
                    $(this).attr('onclick',"pageLoading(this)");
                })
                layer.close(loadingIndex);
            }
		});
		//搜索
		form.on('submit(data-search-btn)', function(data){
			pageLoading();
			var articleFrom = data.field;
			table.reload('testReload', {
			  	url: '{:url("customer_ready", ["t"=>"json"])}',
				where:articleFrom
			});
			return false;
		});
		//监听操作栏事件
		table.on('tool(currentTableFilter)', function (obj) {
			var data = obj.data;
			switch (obj.event) {
				case 'mx':
					get_mingxi(data.id);
				break;
			}
		});
		// 明细
		function get_mingxi(id){
			layer.open({
				type: 2,
				title:'明细',
				area: ['90%', '90%'],
				fixed: false, //不固定
				maxmin: true,
				shadeClose:false,	//点击遮罩后关闭提示框
				scrollbar:false, //- 是否允许浏览器出现滚动
				content: "{:url('customer_mingxi')}?id="+id 
			});
		}
	});
</script>

</body>
</html>